package com.edu.shiro.service.impl;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.edu.shiro.domain.SysRole;
import com.edu.shiro.mapper.RoleMapper;
import com.edu.shiro.service.RoleService;

@Service
public class IRoleService implements RoleService {
	
	@Autowired
	private RoleMapper roleMapper;
	
	
	@Override
	public Set<String> selectRoleKeys(Long userId) {
		List<SysRole> perms = roleMapper.selectRolesByUserId(userId);
        Set<String> permsSet = new HashSet<>();
        for (SysRole perm : perms)
        {
            if (null != perm)
            {
                permsSet.add(perm.getRoleKey().trim());
            }
        }
        return permsSet;
	}
	
}
